package com.whu.tcx01.hd.road;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class NodeDriver2 {

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        // 1 获取job
        Configuration configuration = new Configuration();
        Job job = Job.getInstance(configuration);

        // 2 设置jar
        job.setJarByClass(NodeDriver2.class);

        //3 关联mapper 和 reducer
        job.setMapperClass(NodeMapper.class);
        job.setReducerClass(NodeReducer.class);

        //4 设置mapper 输出的key和Value类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(NodeBean.class);

        //5 设置最终输出的key 和 value 类型
        job.setOutputValueClass(Text.class);
        job.setOutputValueClass(OutNodeBean.class);

        //6 设置数据的输入路径和输出路径
        FileInputFormat.setInputPaths(job, new Path("D:\\test2\\cx\\out1\\outFirst.txt"));
        FileOutputFormat.setOutputPath(job, new Path("D:\\test2\\cx\\out2"));

        // 7 提交job
        boolean b = job.waitForCompletion(true);
        System.exit(b?0:1);
    }
}
